#pragma once
#include "Texture.h"
#include "RenderSystem.h"
#include <list>
using namespace std;
#include "Singleton.h"
namespace NBE
{
	class NBE_API TextureManager: public Singleton<TextureManager>
	{
	public:
		TextureManager();
		~TextureManager();

		Texture* LoadFromMemory(wchar_t* texName, Texture::Size width, Texture::Size height, 
			unsigned int format, unsigned int type, 
			void* pRGBATexels );
 
		Texture* LoadFromMemory(char* texName, Texture::Size width, Texture::Size height,
			unsigned int format, unsigned int type, void* pRGBATexels );

		Texture* CreateTexture( 
			const wchar_t* szTexturePath );

		void DestroyTexture( Texture*& pTexture );
		void DestroyTexture( unsigned int id);

		Texture* LoadFromFile( 
			const wchar_t* szTexturePath );
		
		Texture* LoadFromFile( 
			const char* szTexturePath );

		void UpdateTexture(Texture*& pTexture, void* data, unsigned int width, unsigned int height,
			unsigned int format, unsigned int type);

		unsigned char* getTexturePixel(std::wstring& filePath);
		
		Texture* getTexture(wstring& szTexturePath );
		Texture* getTexture(string& szTexturePath );
		Texture* getTexture(unsigned int id);

		void DestroyAllTextures();

		void initialize(RenderSystem* renderer);
		Texture* getDefaultTex();
		Texture* addTextureByIdx(unsigned int idx);
	private:
		bool isPowerOfTwo(unsigned int num);
		list<Texture*> m_loadedTextures;
		RenderSystem* m_currentRenderer;

	};

}
